﻿namespace FFF.Test.Application.Mqs
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Threading.Tasks;
    using Abp.Dependency;
    using Abp.MqMessages;

    /// <summary>
    /// 测试rabbitMq发布
    /// </summary>
    /// <remarks>于大明</remarks>
    public interface ITestMqMessagePublisher : ITransientDependency
    {
        /// <summary>
        /// Publishes the asynchronous.
        /// </summary>
        /// <param name="messageData">消息参数</param>
        /// <returns>Task.</returns>
        /// <remarks>于大明 2019-12-12</remarks>
        Task PublishAsync(TestMqMessageData messageData);
    }

    /// <summary>
    /// 测试rabbitMq发布
    /// </summary>
    /// <remarks>于大明</remarks>
    public class TestMqMessagePublisher : ITestMqMessagePublisher
    {
        private readonly IMqMessagePublisher _publisher;

        /// <summary>
        /// Initializes a new instance of the <see cref="TestMqMessagePublisher"/> class.
        /// </summary>
        /// <param name="publisher">消息发布者</param>
        /// <remarks>于大明</remarks>
        public TestMqMessagePublisher(IMqMessagePublisher publisher)
        {
            this._publisher = publisher;
        }

        /// <summary>
        /// Publishes the asynchronous.
        /// </summary>
        /// <param name="messageData">消息参数</param>
        /// <returns>Task.</returns>
        /// <remarks>于大明 2019-12-12</remarks>
        public async Task PublishAsync(TestMqMessageData messageData)
        {
            await this._publisher.PublishAsync(messageData);
        }

    }

    /// <summary>
    /// 测试发布消息参数
    /// </summary>
    /// <remarks>于大明</remarks>
    public class TestMqMessageData
    {
        /// <summary>
        /// 消息的值
        /// </summary>
        /// <value>The value.</value>
        /// <remarks>于大明</remarks>
        public string Value { get; set; }

        /// <summary>
        /// 消息时间
        /// </summary>
        /// <value>The time.</value>
        /// <remarks>于大明</remarks>
        public DateTime Time { get; set; }
    }
}
